package com.food.user.commos;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class Result<T> {
    private Boolean flag; //用于描述当前这次请求是否成功了

    private Integer code; //返回给前端的业务状态码

    private String message;//用于描述本次请求的相关信息

    private T data;    //真实返回给前端的数据

    public static Result success(Integer code,String message,Object data){
        Result r = new Result<>();
        r.setFlag(true);
        r.setCode(code);
        r.setMessage(message);
        r.setData(data);
        return r;
    }
    public static Result fail(Integer code,String message){
        Result r = new Result<>();
        r.setFlag(false);
        r.setCode(code);
        r.setMessage(message);
        return r;
    }
}
